<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <%@ include file="/common/plateform/include/common-base.jsp"%>
  <title>审核规则设置</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>

<!-- Part 一、 以下是body主体内容的模块区域 -->
<body class="hold-transition ${sysColor} sidebar-mini">
<div class="wrapper">

  <!-- top start -->
  <%@include file="/common/plateform/top.jsp" %>
  <!-- top end -->
  <!-- left start -->
  <%@include file="/common/plateform/left-project.jsp" %>
  <!-- left end-->

  <div class="content-wrapper">
    <!-- Main start -->
	<section class="content">
      <div class="row">
        <div class="col-xs-12">
        
          <!------搜索  start ------->
          <div class="box box-info">
             <!--搜索title  start --> 
	          <div class="box-header with-border">
                 <h3 class="box-title"><i class="fa fa-search"></i> 审核规则设置搜索</h3>
              </div>
            <!--搜索title  end --> 
            <div class="box-body">
			  <form id="searchForm" class="form-horizontal">
				<input type="hidden" name="pageName" value="audit-rule-list">
				<input type="hidden" name="formName" value="searchForm">
				<input type="hidden" name="orderBy" value="sysAuditRule.audit_type,sysAuditRule.num,sysAuditRule.create_time desc">
				<input type="hidden" name="sysAuditRule.w_sysName" value=""/>
				  <div class="form-group">
					  <div class="form-group col-sm-2 text-right"><label class="control-label" >流程编号：</label></div>
					  <div class="form-group col-sm-3 form-control-static">
						  <input type="hidden" class="form-control" readonly="readonly"  name="sysAuditRule.w_auditType" value="${param.flowNo}"/>
						  <span class="">${param.flowNo}</span>
					  </div>
					  <div class="form-group col-sm-2 text-right"><label class="control-label" >流程名称：</label></div>
					  <div class="form-group col-sm-3 form-control-static">
						  <span>${param.flowName}</span>
					  </div>
				  </div>
				<div class="form-group">
					<div class="form-group col-sm-2 text-right"><label class="control-label" >节点名称：</label></div>
					<div class="form-group col-sm-3">
						<input type="text" class="form-control clean"  name="sysAuditRule.wl_taskName" value=""/>
					</div>
					<div class="form-group col-sm-2 text-right"><label class="control-label" >节点编号：</label></div>
					<div class="form-group col-sm-3">
						<input type="text" class="form-control clean"  name="sysAuditRule.wl_taskNo" value=""/>
					</div>
				</div>
				<center>
				   <div class="form-group col-sm-12  clearfix">
				       <button type="button" class="btn btn-success" onclick="getTableData();"><i class="fa fa-edit-circle"></i> 查询</button> 
				       <button type="button" class="btn btn-warning" onclick="mytools.cleanData('#searchForm');">重置 </button>
				   </div>
				</center>
				
			  </form>
            </div>
	     </div>
	     <!------- 搜索 end -------->
           
        <!------- 列表 start -------->
          <div class="box box-success">
            <!--列表title  start --> 
	          <div class="box-header with-border">
                 <h3 class="box-title"><i class="fa fa-user"></i> 审核规则设置列表
                     <button  onclick="toAdd();" class="btn btn-success" type="button"><i class="fa fa-plus-circle"></i> 增加规则 </button> &nbsp;
					 <button  onclick="toBack('${page_admin}/project/audit-flow-list');" class="btn btn-primary" type="button"><i class="fa fa-reply"></i> 返回上级</button>
                 </h3>
              </div>
            <!--列表title  end --> 
              <div class="box-body">
                <table id="dataList" class="table table-bordered table-hover" >
                <thead class="bg-success">
                <tr>
						<th class="text-center">审核类型</th>
						<th class="text-center">审核次数/节点名称/是否起点/节点编号/审核人员</th>
						<th class="text-center">下一节点</th>
                  		<th class="text-center">操作</th>
                </tr>
                </thead>
                <tbody id="dataList-body">
                </tbody>
              </table>
              <center>
    	  		<ul id="dataList-page"></ul>
              </center>
            </div>
           </div>
        <!------- 列表 end -------->
        </div>
      </div>
    </section>
    <!-- Main end -->
    
    <div win-title="添加窗口" class="modal fade" id="my_modal_add" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width:900px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">信息添加</font> 
						</h4>
					</div>

					<div class="modal-body">
						
					       <div class="nav-tabs-custom">
					            <ul class="nav nav-tabs" id="myTab-add">
					            </ul>
					              
					            <!-- tab content start -->
					            <div class="tab-content">
					            
					               <div class="tab-pane active" id="tabAdd_1">
					                  <form class="form-horizontal addFormBody" role="form" id="addForm1" action="javascript:void(0)">
					                    <input type="hidden" name="pageName" value="audit-rule-list"/>
										<input type="hidden" name="formName" value="addForm"/>
									    <input type="hidden" class="formToken" id="addForm1_formToken" name="formToken" />
										
							            <!--sysAuditRule start-->
										<input type="hidden" name="sysAuditRule.delStatus" value="F"/><!--模板自带-->
										<input type="" name="sysAuditRule.sysName" value=""/>

											<div class="form-group">
												<label  class="col-sm-2 control-label">节点编号</label>
												<div class="col-sm-4">
														<input type="text" id="addForm1_sysAuditRule_taskNo" name="sysAuditRule.taskNo" class="form-control clean"  placeholder="必填项"  maxlength="30"/>
												</div>
												<label  class="col-sm-2 control-label">节点名称</label>
												<div class="col-sm-4">
														<input type="text" id="addForm1_sysAuditRule_taskName" name="sysAuditRule.taskName" class="form-control clean"  placeholder="必填项"  maxlength="30"/>
												</div>
												
											</div>
						                	<div class="form-group">
												<label  class="col-sm-2 control-label">起始节点</label>
												<div class="col-sm-4">
						                			<div id="addForm1_sysAuditRule_ifStart" data-url="doCode=dictItemList&cateEname=yesOrNo" data-type="radio"></div>
												</div>
												<label  class="col-sm-2 control-label">审核次数</label>
												<div class="col-sm-4">
														<input type="text" id="addForm1_sysAuditRule_num" name="sysAuditRule.num" class="form-control clean"  placeholder="必填项"  maxlength="30"/>
												</div>
											</div>
						                	<div class="form-group">
												<label  class="col-sm-2 control-label">审核人</label>
												<div class="col-sm-6">
														<input type="text" id="addForm1_sysAuditRule_checkUser" name="sysAuditRule.checkUser" class="form-control clean"  placeholder="必填项"  maxlength="30"/>
												</div>
												<div class="col-sm-4">
														<input type="button" value="选择审核人" onclick="searchAuditUser('addForm1')">
														<select id="addForm1_search_actroles" style="display: none;width: 60%" class="form-control" onchange="getUserStr(this.value,'addForm1');" ></select>												</div>
											</div>
											
											
											
											
											
											<div class="form-group">
											
												<label  class="col-sm-2 control-label">是否自定义</label>
												<div class="col-sm-4">
						                			<div id="addForm1_sysAuditRule_ifCustom" data-url="doCode=dictItemList&cateEname=yesOrNo" data-type="radio"></div>
												</div>
											
												<label  class="col-sm-2 control-label">审核类型</label>
												<div class="col-sm-4">
													<input type="text" id="addForm1_sysAuditRule_auditType" name="sysAuditRule.auditType" class="form-control clean"  placeholder="必填项"  maxlength="30"/>
												</div>
											
											</div>
											
											<div class="form-group">
											
												<label  class="col-sm-2 control-label">审核地址</label>
												<div class="col-sm-4">
														<input type="text" readonly="readonly" id="addForm1_sysAuditRule_toUrl" name="sysAuditRule.toUrl" class="form-control"  placeholder="例如：/rule/audit/common-audit"  value="/rule/audit/common-audit"/>
												</div>
												<label  class="col-sm-2 control-label">引用地址</label>
												<div class="col-sm-4">
														<input type="text" id="addForm1_sysAuditRule_linkUrl" name="sysAuditRule.linkUrl" class="form-control clean"  placeholder=""  maxlength="30"/>
												</div>
												
												
											</div>
											
											<div class="form-group">
												<label  class="col-sm-2 control-label">对象名</label>
												<div class="col-sm-4">
													<input type="text" id="addForm1_sysAuditRule_tableName" name="sysAuditRule.tableName" class="form-control clean"  placeholder="选填项"  maxlength="30"/>
												</div>
												<label  class="col-sm-2 control-label">属性名</label>
												<div class="col-sm-4">
														<input type="text" id="addForm1_sysAuditRule_colName" name="sysAuditRule.colName" class="form-control clean"  placeholder="选填项"  maxlength="30"/>
												</div>
											</div>
											<div class="form-group">
												<label  class="col-sm-2 control-label">pageName</label>
												<div class="col-sm-4">
													<input type="text" id="addForm1_sysAuditRule_pageName" name="sysAuditRule.pageName" class="form-control clean"  placeholder="选填项"  maxlength="30"/>
												</div>
												<label  class="col-sm-2 control-label">formName</label>
												<div class="col-sm-4">
														<input type="text" id="addForm1_sysAuditRule_formName" name="sysAuditRule.formName" class="form-control clean"  placeholder="选填项"  maxlength="30"/>
												</div>
											</div>
											<div class="form-group">
												<label  class="col-sm-2 control-label">待修改字段<br/>(通过)</label>
												<div class="col-sm-10">
														<input type="text" id="addForm1_sysAuditRule_colNameY" name="sysAuditRule.colNameY" class="form-control clean"  placeholder="" />
												</div>
											</div>
											<div class="form-group">
												<label  class="col-sm-2 control-label">待修改字段<br/>(不通过)</label>
												<div class="col-sm-10">
														<input type="text" id="addForm1_sysAuditRule_colNameN" name="sysAuditRule.colNameN" class="form-control clean"  placeholder="" />
												</div>
											</div>
								        <!--sysAuditRule end-->
								        
					                    
					                    <div class="form-group">
								        	<div class="col-sm-12">
									         <div class="box-footer text-center">
												<button class="btn btn-success pull-left" type="button" onclick="mytools.closeModal('my_modal_add');"> 取消 </button>
				                				<button class="btn btn-danger pull-right" type="button" onclick="submitForm1('addForm1');"> 提 交 </button>
					            			</div>
				            				</div>
				            			</div>
					                  </form>
					               </div>
					          
				            </div>
					            <!-- tab content e -->
				          </div>	
			                
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>  
    
<div win-title="修改窗口" class="modal fade" id="my_modal_edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width:900px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">信息修改</font> 
						</h4>
					</div>
					<div class="modal-body">
						 <div class="nav-tabs-custom">
					            <ul class="nav nav-tabs" id="myTab-edit">
					            </ul>
					            
					            <!-- tab content start -->
					            <div class="tab-content">
					            
					               <div class="tab-pane active" id="tabEdit_1">
					                  <form class="form-horizontal editFormBody" role="form" id="editForm1" action="javascript:void(0)">
					                    <input type="hidden" name="pageName" value="audit-rule-list"/>
										<input type="hidden" name="formName" value="editForm"/>
									    <input type="hidden" class="formToken" id="editForm1_formToken" name="formToken" />
									    <input type="hidden" class="clean" id="editForm1_sysAuditRule_ruleId" name="sysAuditRule.w_ruleId" data-name="sysAuditRule.ruleId"/>
										
							            <!--sysAuditRule start-->
					        			<input type="hidden" class="clean" data-name="sysAuditRule.ruleId" name="sysAuditRule.w_ruleId" id="editForm1_sysAuditRule_w_ruleId" value=""><!--this is sysAuditRule primaryKeyId 主键-->
						                	<div class="form-group">
												<label  class="col-sm-2 control-label">节点编号</label>
												<div class="col-sm-4">
														<input type="text" id="editForm1_sysAuditRule_taskNo" name="sysAuditRule.taskNo" data-name="sysAuditRule.taskNo" class="form-control clean"  placeholder="必填项"  maxlength="30"/>
												</div>
												<label  class="col-sm-2 control-label">节点名称</label>
												<div class="col-sm-4">
														<input type="text" id="editForm1_sysAuditRule_taskName" name="sysAuditRule.taskName" data-name="sysAuditRule.taskName" class="form-control clean"  placeholder="必填项"  maxlength="30"/>
												</div>
											</div>
						                	<div class="form-group">
												<label  class="col-sm-2 control-label">起始节点</label>
												<div class="col-sm-4">
						                			<div id="editForm1_sysAuditRule_ifStart" data-url="doCode=dictItemList&cateEname=yesOrNo" data-type="radio"></div>
												</div>
												<label  class="col-sm-2 control-label">审核次数</label>
												<div class="col-sm-4">
														<input type="text" id="editForm1_sysAuditRule_num" name="sysAuditRule.num" data-name="sysAuditRule.num" class="form-control clean"  placeholder="必填项"  maxlength="30"/>
												</div>
											</div>
											
						                	<div class="form-group">
												<label  class="col-sm-2 control-label">审核人</label>
												<div class="col-sm-6">
														<input type="text" id="editForm1_sysAuditRule_checkUser" name="sysAuditRule.checkUser" data-name="sysAuditRule.checkUser" class="form-control clean"  placeholder="必填项"  maxlength="30"/>
												</div>
												<div class="col-sm-4">
														<input type="button" value="选择审核人" onclick="searchAuditUser('editForm1')">
														<select id="editForm1_search_actroles" onchange="getUserStr(this.value,'editForm1');" style="display: none"></select>												
												</div>
											</div>
											
											
											<div class="form-group">
												<label  class="col-sm-2 control-label">是否自定义</label>
												<div class="col-sm-4">
						                			<div id="editForm1_sysAuditRule_ifCustom"  data-url="doCode=dictItemList&cateEname=yesOrNo" data-type="radio"></div>
												</div>
												<label  class="col-sm-2 control-label">审核类型</label>
												<div class="col-sm-4">
														<input type="text" id="editForm1_sysAuditRule_auditType" name="sysAuditRule.auditType" data-name="sysAuditRule.auditType" class="form-control clean"  placeholder="必填项"  maxlength="30"/>
												</div>
											</div>
											
											<div class="form-group">
												<label  class="col-sm-2 control-label">审核地址</label>
												<div class="col-sm-4">
														<input type="text" id="editForm1_sysAuditRule_toUrl" readonly="readonly" name="sysAuditRule.toUrl" data-name="sysAuditRule.toUrl" class="form-control clean"  placeholder="必填项"  maxlength="30"/>
												</div>
												<label  class="col-sm-2 control-label">引用地址</label>
												<div class="col-sm-4">
														<input type="text" id="editForm1_sysAuditRule_linkUrl" name="sysAuditRule.linkUrl" data-name="sysAuditRule.linkUrl" class="form-control clean"  placeholder=""  maxlength="30"/>
												</div>
											</div>
											
											<div class="form-group">
												<label  class="col-sm-2 control-label">对象名</label>
												<div class="col-sm-4">
													<input type="text" id="editForm1_sysAuditRule_tableName" name="sysAuditRule.tableName" data-name="sysAuditRule.tableName" class="form-control clean"  placeholder="选填项"  maxlength="30"/>
												</div>
												<label  class="col-sm-2 control-label">属性名</label>
												<div class="col-sm-4">
													<input type="text" id="editForm1_sysAuditRule_colName" name="sysAuditRule.colName" data-name="sysAuditRule.colName" class="form-control clean"  placeholder="选填项"  maxlength="30"/>
												</div>
											</div>
											<div class="form-group">
												<label  class="col-sm-2 control-label">pageName</label>
												<div class="col-sm-4">
													<input type="text" id="editForm1_sysAuditRule_pageName" name="sysAuditRule.pageName" data-name="sysAuditRule.pageName" class="form-control clean"  placeholder="选填项"  maxlength="30"/>
												</div>
												<label  class="col-sm-2 control-label">formName</label>
												<div class="col-sm-4">
													<input type="text" id="editForm1_sysAuditRule_formName" name="sysAuditRule.formName" data-name="sysAuditRule.formName" class="form-control clean"  placeholder="选填项"  maxlength="30"/>
												</div>
											</div>
											
											<div class="form-group">
												<label  class="col-sm-2 control-label">待修改字段<br/>(通过)</label>
												<div class="col-sm-10">
													<input type="text" id="editForm1_sysAuditRule_colNameY" name="sysAuditRule.colNameY"  data-name="sysAuditRule.colNameY" class="form-control clean"  placeholder="" />
												</div>
											</div>
											
											<div class="form-group">
												<label  class="col-sm-2 control-label">待修改字段<br/>(不通过)</label>
												<div class="col-sm-10">
													<input type="text" id="editForm1_sysAuditRule_colNameN" name="sysAuditRule.colNameN" data-name="sysAuditRule.colNameN" class="form-control clean"  placeholder="" />
												</div>
											</div>
											
								       <!--sysAuditRule end-->
								       
					                    
					                    <div class="form-group">
								        	<div class="col-sm-12">
									         <div class="box-footer text-center">
												<button class="btn btn-success pull-left" type="button" onclick="mytools.closeModal('my_modal_edit');"> 取消 </button>
				                				<button class="btn btn-danger pull-right" type="button" onclick="submitForm1('editForm1');"> 提 交 </button>
					            			</div>
				            				</div>
				            			</div>
					                  </form>
					               </div>
					          
				            </div>
					            <!-- tab content e -->
				          </div>	
					</div>
				</div>
				<!-- /.modal-content -->
	</div>		
</div>      
 
 
 
 <div win-title="查看窗口" class="modal fade" id="my_modal_view" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width:900px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">查看详情</font> 
						</h4>
					</div>
					<div class="modal-body">
						<div class="nav-tabs-custom">
					            <ul class="nav nav-tabs" id="myTab-view">
					            </ul>
					            
					            <!-- tab content start -->
					            <div class="tab-content">
					            
					               <div class="tab-pane active" id="tabView_1">
					                  <form class="form-horizontal" role="form" id="viewForm1" action="javascript:void(0)">
							            <!--sysAuditRule start-->
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">节点名称</label>
												<div class="col-sm-8">
													<span data-name="sysAuditRule.taskName"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">起始节点</label>
												<div class="col-sm-8">
						                			<span data-name="sysAuditRule.ifStart" data-dict-url="doCode=dictItemList&cateEname=yesOrNo"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">业务表名称</label>
												<div class="col-sm-8">
													<span data-name="sysAuditRule.tableName"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">审核人</label>
												<div class="col-sm-8">
													<span data-name="sysAuditRule.checkUser"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">通过跳转至</label>
												<div class="col-sm-8">
						                			<span data-name="sysAuditRule.next"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">不通过跳转至</label>
												<div class="col-sm-8">
						                			<span data-name="sysAuditRule.last" ></span>
												</div>
											</div>
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">审核次数</label>
												<div class="col-sm-8">
													<span data-name="sysAuditRule.num"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">审核类型</label>
												<div class="col-sm-8">
													<span data-name="sysAuditRule.auditType"></span>
												</div>
											</div>
											<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">审核地址</label>
												<div class="col-sm-8">
													<span data-name="sysAuditRule.toUrl"></span>
												</div>
											</div>
								       <!--sysAuditRule end-->
								       
					                    
					                    <div class="form-group">
								        	<div class="col-sm-12">
									         <div class="box-footer text-center">
												<button class="btn btn-success pull-right" type="button" onclick="mytools.closeModal('my_modal_view');"> 关闭 </button>
					            			</div>
				            				</div>
				            			</div>
					                  </form>
					               </div>
				            </div>
					            <!-- tab content e -->
				          </div>
					</div>
				</div>
				<!-- /.modal-content -->
	</div>		
</div>
 
 
 
 <!-- Part 二、以下是template模板定义的模块区域 -->
<script type="text/template" id="dataList-template">
		<? for ( var i = 0; i < rows.length; i++) {?>
		<tr>
				<td class="text-center" style="vertical-align:middle;"><?=strUtil.doNull(rows[i].auditType,'')?></td>
				<td class="text-left">
						<div class="form-group lh30">
							<small class="badge bg-green"><?=strUtil.doNull(rows[i].num,'')?></small> 
							<?=strUtil.doNull(rows[i].taskName,'')?> 
							<?if(rows[i].ifStart=='T'){?>
								<small class="badge bg-red">起点</small>
							<?}?>
						</div>
						<div class="form-group lh30">
							<label class="label label-primary"><?=strUtil.doNull(rows[i].taskNo,'')?></label> 
							<?=strUtil.doNull(rows[i].checkUser,'')?>
						</div>
				</td>
				<td class="text-center w250">
					<div class="input-group">
						<div class="input-group-addon fx1 w100">
							<i class="fa fa-check"></i> 通 过To 
						</div>
						<input type="text" class="form-control fx1 b" data-type="next" onblur="saveNextRule('<?=rows[i].ruleId?>',this)" value="<?=strUtil.doNull(rows[i].next,'')?>" maxlength="6"/>
						<?if(rows[i].next=='00'){?>
							<div class="input-group-addon fx8">end</div>
						<?}?>
					</div>
					<div class="input-group ">
						<div class="input-group-addon fx7 w100">
							<i class="fa fa-close"></i> 不通过To
						</div>
						<input type="text" class="form-control fx7 b" data-type="last" onblur="saveNextRule('<?=rows[i].ruleId?>',this)" value="<?=strUtil.doNull(rows[i].last,'')?>" maxlength="6"/>
						<?if(rows[i].last=='00'){?>
							<div class="input-group-addon fx8">end</div>
						<?}?>
					</div>
				</td>
              	<td class="text-center" style="vertical-align:middle;">
						<button type="button" class="btn btn-success btn-xs" onclick="toLoad('<?=rows[i].ruleId?>','view')">查看</button>  
						<br/><button type="button" class="btn btn-warning btn-xs" onclick="toLoad('<?=rows[i].ruleId?>','edit');">修改</button>  
						<button type="button" class="btn btn-danger btn-xs" onclick="toDele('<?=rows[i].ruleId?>');">删除</button>
				</td>
		</tr>
   <?}?>  		
</script>
 
<!-- Part 三、 以下是js模块区域 -->
<script>
var clickMenu = "audit-rule-list";//"audit-rule-list";
var myPage,dataListId,searchFormId,mainObj,mainId;
myPage = 10;//定义列表数据
dataListId = "dataList";//显示列表数据div的id
searchFormId = "searchForm";//搜索表单Id
mainObj = "sysAuditRule";//主对象
mainId = "ruleId";//主对象主键
var defSysEname = strUtil.doNull(strUtil.getLocalStorage("sysEname"), "");
$("#"+searchFormId).find("input[name='sysAuditRule.w_sysName']").val(defSysEname);
$("#addForm1").find("input[name='sysAuditRule.sysName']").val(defSysEname);
console.log(defSysEname)
$(function () {
	//1、加载分页列表数据
	getTableData();
	
	//2、控制是否启用token
	//setToken();
	
	//可在下面补充其他初始化方法（如数据字典、页面加载数据等）
	DictUtil.getCommonDictData("radio","#addForm1_sysAuditRule_ifStart","sysAuditRule.ifStart","doCode=dictItemList&cateEname=yesOrNo","","");
	DictUtil.getCommonDictData("radio","#addForm1_sysAuditRule_ifCustom","sysAuditRule.ifCustom","doCode=dictItemList&cateEname=yesOrNo","","");
 });
 
 $(function () {
	//设置数据行选中效果
	$('#'+dataListId+' tbody').on('click','tr', function (e) {
	     if ( $(this).hasClass('selected') ) {
	        }
	        else {
	            $('tr.selected').removeClass('selected');
	            $(this).addClass('selected');
	        }
	     //var id = $('tr.selected th').eq(0).html();
	} );
 });
//日历框添加样式
var dateObject = $('.datepicker').datepicker( {
	language : 'zh-CN',
	//inline: true,
	todayBtn : "linked",
	format : "yyyy-mm-dd",
	autoclose: true
});
//打开添加页面
function toAdd(){
	mytools.cleanData(".addFormBody");//清空表单元素上次填写的内容；
	setValidate(".addFormBody");//定义add表单验证属性
	mytools.cleanValidate(".addFormBody");//清空上次校验规则提示
	$(".datepicker").val("");
	//初始化数据字典
	
	$("input:radio[name='sysAuditRule.ifCustom']").click(function(){
		 var selectVal = $(this).val();
		 if(selectVal=="T"){
			 $("#addForm1_sysAuditRule_toUrl").attr("readonly",false);
			 $("#addForm1_sysAuditRule_linkUrl").attr("readonly",true);
		 }else{
			 $("#addForm1_sysAuditRule_toUrl").attr("readonly",true);
			 $("#addForm1_sysAuditRule_linkUrl").attr("readonly",false);
		 }	
	});
	$("#my_modal_add").modal("show");
}
//数据toLoad读取（查询、编辑）数据
function toLoad(id,type){
	var formName = $("#searchForm").find("input[name='formName']").val();
	var paramLoadData = {"pageName":"audit-rule-list","formName":formName,"sysAuditRule.w_ruleId":id};
	showModal(type);//控制弹出view/edit窗口
	$.ajax({
	    type:'get',
	   	url:common_info_url,
	    data: paramLoadData,
	    async:false,
	    dataType:"json",
	    success: function(myData){
	    	console.log(myData);
	    	
			if("edit"==type){		
				DictUtil.getCommonDictData("radio","#editForm1_sysAuditRule_ifStart","sysAuditRule.ifStart","doCode=dictItemList&cateEname=yesOrNo","",myData.ifStart);
				DictUtil.getCommonDictData("radio","#editForm1_sysAuditRule_ifCustom","sysAuditRule.ifCustom","doCode=dictItemList&cateEname=yesOrNo","",myData.ifCustom);
				if(myData.ifCustom=="T"){
					 $("#editForm1_sysAuditRule_toUrl").attr("readonly",false);
					 $("#editForm1_sysAuditRule_linkUrl").attr("readonly",true);
				}else{
					 $("#editForm1_sysAuditRule_toUrl").attr("readonly",true);
					 $("#editForm1_sysAuditRule_linkUrl").attr("readonly",false);
				 }	
				
				$("input:radio[name='sysAuditRule.ifCustom']").click(function(){
					 var selectVal = $(this).val();
					 if(selectVal=="T"){
						 $("#editForm1_sysAuditRule_toUrl").attr("readonly",false);
						 $("#editForm1_sysAuditRule_linkUrl").attr("readonly",true);
					 }else{
						 $("#editForm1_sysAuditRule_toUrl").attr("readonly",true);
						 $("#editForm1_sysAuditRule_linkUrl").attr("readonly",false);
					 }	
				});
			}
			/**
			if("rule"==type){		
				DictUtil.getCommonDictData("select","#editRuleForm_sysAuditRule_next","sysAuditRule.next","doCode=dymicSql&modelTypes=s_sysAuditRule","{value:'taskNo',text:'taskName'}",myData.next);
				DictUtil.getCommonDictData("select","#editRuleForm_sysAuditRule_last","sysAuditRule.last","doCode=dymicSql&modelTypes=s_sysAuditRule","{value:'taskNo',text:'taskName'}",myData.last);
			}
			**/
			//反显加载数据
			FormUtil.loadView("sysAuditRule", myData);
		
	  	}
	});
}
//删除调用
function toDele(id){
	var index_submit = layer.confirm('您确定要删除信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		var paramData = {"pageName":"audit-rule-list","formName":"delForm","sysAuditRule.w_ruleId":id};
		$.ajax({
	    	type:"post",
	    	url:common_submit_url,
	    	data: paramData,dataType:"json",
	    	success: function(myData){
	    		var result = myData.flag;
	    		if(result=="T"){
	    			refresh();
	    		}else{
	    			layer.alert("删除失败！");
	    		}
	  		}
		});	
	});
}

//弹出框
function showModal(type){
	if("view"==type){
		$("#my_modal_view").modal("show");
	}else if("edit"==type){
		mytools.cleanData(".editFormBody");//清空表单元素上次填写的内容；
		setValidate(".editFormBody");//定义edit表单验证属性
		mytools.cleanValidate(".editFormBody");//清空上次校验规则提示
		$("#my_modal_edit").modal("show");
	}
	/**
	else if("rule"==type){
		setValidate(".editFormBody");//定义edit表单验证属性
		mytools.cleanValidate(".editFormBody");//清空上次校验规则提示
		$("#my_modal_rule").modal("show");
	}
	**/
}
//加载列表数据
function getTableData(){
	deleteAllRow(dataListId);
	$.ajax({
		   type:'get',
		   url:common_list_url,
		   data:$("#"+searchFormId).serialize()+getCurrentPage(common_list_url+"?"+$("#"+searchFormId).serialize(),myPage),
		   dataType:'json',
		   success: function(myData){
		   console.log(myData);
			var data = baidu.template(dataListId+"-template",eval(myData));  
			$("#"+dataListId+"-body").html(data);
			  var option= {
					   ele:$("#"+dataListId+"-page")[0],
					   total:myData.total,
					   fn:getTableData,
					   url:common_list_url+"?"+$("#"+searchFormId).serialize()
				   }
				generatePages(option);
			  
			  /**
			  $(".btn-pover-tools").click(function(){
					var thisId = $(this).attr("id");
					layer.tips($("#pover-tools-target").html(), "#"+thisId, {
					    tips: [3,"#f0f0f0"],
					    area: ['350px', 'auto'],
					    time: 3000
					});
				});
			  **/
		   }
		});	
  }


//提交tab1表单数据
function submitForm1(formId,tabId){
	//校验规则-表单提交时触发
	var validate = $('#'+formId).data('bootstrapValidator').validate();
	if(!validate.isValid()){ //如果校验不通过就返回
	    return;  
	}
	
	var index_submit = layer.confirm('您确定要保存信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		var result = submitForm(formId,tabId);
		if(result){
      		layer.alert('操作成功！', {closeBtn: 0 });
      		mytools.closeModal("my_modal_add");
      		mytools.closeModal("my_modal_edit");
      		//mytools.closeModal("my_modal_rule");
      		refresh();
		
    		var num = formId.slice(-1);
    		if(num!=null &&　num !=""){
    			num=parseInt(num)+1;
    			defaultTab = "#tab_"+num;
    		}
      		//setToken();
      		//if(tabId!=null && tabId!=""){
      		//	tabId = "#"+tabId;
      		//	$('#myTab a[href=\"'+tabId+'\"]').tab('show'); // Select tab by name 
      		//}
	  	}
	});
	
 }
//提交表单数据
function submitForm(formId,tabId){
	var result;
	if(tabId!=null && tabId!="" && tabId!="undefined"){
	}else{
		var proName = $("#"+formId+"_proName").val();
	}
	var index_load = layer.load(1, {shade: false});
	$.ajax({
	    type:'post',
	    url:common_submit_url,
	    data:$("#"+formId).serialize(),
	    async:false,
	    dataType:'json',
	    success: function(myData){ 
	     console.log(myData);
	        if(myData.flag=="T"){
	        	result = myData;
	    	}else{
	    		setToken();
	     		layer.alert(myData.msg);
	    	}
	        layer.close(index_load);
	  	},
	     error: function (e) {
		     layer.close(index_load);
     	} 
	});	
	return result;
}

//刷新
function refresh(){
	getTableData();
}
//设置token
function setToken(){
	$.ajax({
	    type:'get',
	    url:'${ctx}/sendPage/token?token=true',
	    dataType:'text',
	    success: function(myData){
	    	console.log(myData);
			$('.formToken').val(myData);
	  	}
	});	
}

function toBack(url){
    var page="1";
    if(page){
        sessionStorage.setItem("page",page);
    }
    mytools.pjax(url);
}

/**** Part 四、以下是自定义新增方法  ****/
//1.定义校验规则-定义
function setValidate(id){
	$(id).bootstrapValidator({
	    feedbackIcons: {
	        valid: 'glyphicon glyphicon-ok',
	        invalid: 'glyphicon glyphicon-remove',
	        validating: 'glyphicon glyphicon-refresh'
	    },/** 以下需要结合实际业务清空补充个表单元素的验证规则 **/
	    fields: {
	        "trpProduct.proName": {
	            validators: {
	                notEmpty: {
	                    message: '自定义属性不能为空！'
	                }
	            }
	        }
	    }
	});
}

//保存下一步（通过、不通过）规则
function saveNextRule(id,ob){
	var obj = $(ob);
	var type = obj.attr("data-type");
	var value = obj.val();
	var parmData = {};
	parmData["pageName"]="audit-rule-list";
	parmData["formName"]="editForm";
	parmData["sysAuditRule.w_ruleId"]=id;
	if(type=="next"){
		parmData["sysAuditRule.next"]=value;
	}else{
		parmData["sysAuditRule.last"]=value;
	}
	var index_load = layer.load(1, {shade: false});
	$.ajax({
	    type:'post',
	    url:common_submit_url,
	    data:parmData,
	    async:false,
	    dataType:'json',
	    success: function(myData){ 
	     console.log(myData);
	        //layer.msg("保存成功！");
	        layer.close(index_load);
	        getTableData();
	  	},
	     error: function (e) {
     		layer.msg("操作失败！");
		    layer.close(index_load);
     	} 
	});	
}

function searchAuditUser(formId){
	$("#"+formId+"_search_actroles").show();
	$.ajax({type:'get', url:ctx+'/flow/?doCode=actRoles',
	    async:false,dataType:'json',
	    success: function(myData){ 
	        console.log(myData);
	     	if(myData.flag='T'){
	     		$("#"+formId+"_search_actroles").empty();
	     		$("#"+formId+"_search_actroles").append("<option value=''>请选择角色</option>");
	     		$.each(myData.rows, function(index, content){
	     			 $("#"+formId+"_search_actroles").append("<option value='"+content.roleId+"'>"+content.roleCname+"</option>"); 
	     		});
	     	}else{
	     		layer.msg(myData.msg);
	     	}
	  	}
	});	
}

function getUserStr(value,formId){
	$.ajax({type:'get', url:ctx+'/flow/?doCode=actUsers',data:{"roleId":value,"deptcross":"1","deptId":""},
	    async:false,dataType:'json',
	    success: function(myData){ 
	        console.log(myData);
	     	if(myData.flag=='T'){
	     		
	     	   $("#"+formId+"_sysAuditRule_checkUser").val(myData.data);
	     	   $("#"+formId+"_search_actroles").hide();
	     	}else{
	     		layer.msg(myData.msg);
	     	}
	  	}
	});	
}
</script> 
 
    
    
  </div>
  <!-- /.content-wrapper -->
  <!-- foot start -->
  <%@include file="/common/plateform/foot.jsp" %>
  <!-- foot start -->
  





<!-- 
<div win-title="规则窗口" class="modal fade" id="my_modal_rule" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">信息修改</font> 
						</h4>
					</div>
					<div class="modal-body">
						 <div class="nav-tabs-custom">
					            <ul class="nav nav-tabs">
					            </ul>
					            
				
					            <div class="tab-content">
					            
					               <div class="tab-pane active">
					                  <form class="form-horizontal editFormBody" role="form" id="editRuleForm" action="javascript:void(0)">
					                    <input type="hidden" name="pageName" value="audit-rule-list"/>
										<input type="hidden" name="formName" value="editForm"/>
									    <input type="hidden" class="formToken" id="editRuleForm_formToken" name="formToken" />
									    <input type="hidden" class="clean" id="editRuleForm_sysAuditRule_ruleId" name="sysAuditRule.w_ruleId" data-name="sysAuditRule.ruleId"/>
										
							       
					        			<input type="hidden" class="clean" data-name="sysAuditRule.ruleId" name="sysAuditRule.w_ruleId" id="editRuleForm_sysAuditRule_w_ruleId" value="">
					        			
						                	<div class="form-group col-sm-12">
												<label  class="col-sm-4 control-label">当前节点编号</label>
												<div class="col-sm-8">
														<span data-name="sysAuditRule.taskNo"></span>
												</div>
											</div>
											<div class="form-group col-sm-12">
												<label  class="col-sm-4 control-label">当前节点名称</label>
												<div class="col-sm-8">
														<span data-name="sysAuditRule.taskName"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-12">
												<label  class="col-sm-4 control-label">通过跳转至</label>
												<div class="col-sm-8">
						                			<select id="editRuleForm_sysAuditRule_next" data-name="sysAuditRule.next" name="sysAuditRule.next" class="form-control" 
						                			data-url="doCode=dymicSql&modelTypes=s_sysAuditRule" data-colmun="{value:'ruleId',text:'taskName'}" data-type="select">
						                			</select>
												</div>
											</div>
						                	<div class="form-group col-sm-12">
												<label  class="col-sm-4 control-label">不通过跳转至</label>
												<div class="col-sm-8">
						                			<select id="editRuleForm_sysAuditRule_last" data-name="sysAuditRule.last" name="sysAuditRule.last" class="form-control" 
						                			data-url="doCode=dymicSql&modelTypes=s_sysAuditRule" data-colmun="{value:'ruleId',text:'taskName'}" data-type="select">
						                			</select>
												</div>
											</div>
						
								       
					                    
					                    <div class="form-group">
								        	<div class="col-sm-12">
									         <div class="box-footer text-center">
												<button class="btn btn-success pull-left" type="button" onclick="mytools.closeModal('my_modal_rule');"> 取消 </button>
				                				<button class="btn btn-danger pull-right" type="button" onclick="submitForm1('editRuleForm');"> 提 交 </button>
					            			</div>
				            				</div>
				            			</div>
					                  </form>
					               </div>
					          
				            </div>
					           
				          </div>	
					</div>
				</div>
				
	</div>		
</div>  
-->

</body>




</html>





